home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5674 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: ehsn25.cen.uiuc.edu!jroberts
  2. From: jroberts@ehsn25.cen.uiuc.edu (robertson jason victor )
  3. Newsgroups: comp.windows.x.motif,comp.lang.c++
  4. Subject: Re: MOTIF Callbacks, C++ Member Functions - SOLVED
  5. Date: 6 Feb 1996 06:41:30 GMT
  6. Organization: University of Illinois
  7. Distribution: inet
  8. Message-ID: <4f6t6q$7k@vixen.cso.uiuc.edu>
  9. References: <4f6oau$c4m@knot.queensu.ca>
  10. Reply-To: jroberts@uiuc.edu (Jason Robertson)
  11. NNTP-Posting-Host: ehsn25.cen.uiuc.edu
  12.  
  13. In article <4f6oau$c4m@knot.queensu.ca> Wintermute <3mal5@qlink.queensu.ca> writes:
  14. >In case anyone's curious, I have implemented the suggestion I received 
  15. >and it works beautifully.  The problem was wrapping C++ classes around 
  16. >Motif widgets and wanting to use class member functions as callbacks:  
  17. >the implicit 'this' parameter of course made this impossible.
  18. >
  19. >The solution was to declare a static member function which is used as a 
  20. >callback.  Since it is static, there is no 'this' pointer, and it works 
  21. >fine.  To access the particular class instance, pass the 'this' pointer 
  22. >as client data when installing the callback, and it will be available 
  23. >when the static member function is called back.  (I use it to call 
  24. >another member function, but it could be used directly.)
  25. >
  26.  
  27. I don't know if this was recommended earlier, but you might want to check out
  28. 'Object Oriented Programming with C++ and OSF/Motif' by Douglas A. Young.
  29.  
  30. He goes over this method, and a few others (friend functions come to mind).
  31. It's a pretty good book.
  32.